package com.topwater.topwater.service.impl;

import com.topwater.topwater.entity.BeOrder;
import com.topwater.topwater.dao.BeOrderDao;
import com.topwater.topwater.service.BeOrderService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import javax.annotation.Resource;

/**
 * (BeOrder)表服务实现类
 *
 * @author 胡文 qq:986776
 * 自定义生成器制造
 */
@Service("beOrderService")
public class BeOrderServiceImpl implements BeOrderService {
    @Resource
    private BeOrderDao beOrderDao;

    /**
     * 通过ID查询单条数据
     *
     * @param orderno 主键
     * @return 实例对象
     */
    @Override
    public BeOrder queryById(String orderno) {
        return this.beOrderDao.queryById(orderno);
    }


    /**
     * 新增数据
     *
     * @param beOrder 实例对象
     * @return 实例对象
     */
    @Override
    public BeOrder insert(BeOrder beOrder) {
        this.beOrderDao.insert(beOrder);
        return beOrder;
    }

    @Override
    public BeOrder insertNotNull(BeOrder beOrder) {
        this.beOrderDao.insertNotNull(beOrder);
        return beOrder;
    }

    /**
     * 修改数据
     *
     * @param beOrder 实例对象
     * @return 实例对象
     */
    @Override
    public BeOrder update(BeOrder beOrder) {
        this.beOrderDao.update(beOrder);
        return this.queryById(beOrder.getOrderno());
    }

    /**
     * 通过主键删除数据
     *
     * @param orderno 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String orderno) {
        return this.beOrderDao.deleteById(orderno) > 0;
    }

    /**
     * 字符串自动模糊查询
     **/
    public List<BeOrder> queryByLike(BeOrder beOrder) {
        return this.beOrderDao.queryByLike(beOrder);
    }

    public List<BeOrder> queryByLike2(String str) {
        return this.beOrderDao.queryByLike2(str);
    }

    @Override
    public List<BeOrder> queryByLike3(String str) {
        return  this.beOrderDao.queryByLike3(str);
    }

    /**
     * 多表连接查询
     */
    public List<Map> queryJoin(@Param("beOrder") BeOrder beOrder, @Param("tables") String... tables) {
        return this.beOrderDao.queryJoin(beOrder, tables);
    }
}
